#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 998244353;
ll fac[200010];

void init(){
    fac[0] = 1;
    fac[1] = 1;
    for(int i = 2; i < 200010; i++){
        fac[i] = (i * fac[i - 1]) % mod;
    }
}

void solve(){
    int n;
    cin >> n;
    vector<vector<int>> g(n);
    int a, b;

    for(int i = 1; i < n; i++){
        cin >> a >> b;
        g[a - 1].push_back(b - 1);
        g[b - 1].push_back(a - 1);
    }

    auto dfs = [&](auto&& dfs, int x, int fa)->int{
        ll res = 1, cnt = 0;
        for(auto i : g[x]){
            if(i == fa) continue;
            res = (res * dfs(dfs, i, x)) % mod;
            cnt++;
        }
        res = (res * fac[cnt]) % mod;
        return res;
    };

    cout << dfs(dfs, 0, -1) << endl;
}

int main(){
    init();
    int t;
    cin >> t;
    while(t--) solve();
    return 0;
}
